<template>
 <div class="home">
 <router-view></router-view>

 <div class="main_foot">
        <van-tabbar v-model="active" @click="tabchange(active)">
          <van-tabbar-item icon="wap-home">首页</van-tabbar-item>
          <van-tabbar-item icon="smile">社区</van-tabbar-item>
          <van-tabbar-item icon="add">添加食谱</van-tabbar-item>
          <van-tabbar-item icon="goods-collect">清单</van-tabbar-item>
          <van-tabbar-item icon="manager">我的</van-tabbar-item>
        </van-tabbar>
      </div>
 </div>
</template>
<script>
export default{
  name:'HomeView',
  data(){
    return{
      active:0,
    }
  },
  mounted(){
    if(this.$route.path.indexOf('shouye')>0){
    this.active=0
  }else if(this.$route.path.indexOf('shequ')>0){
    this.active=1
  }else if(this.$route.path.indexOf('tianjia')>0){
    this.active=2
  }else if(this.$route.path.indexOf('qingdan')>0){
    this.active=3
  }else if(this.$route.path.indexOf('wode')>0){
    this.active=4
  }
  },
  methods:{
    tabchange(idx){
      if(idx==0){
        this.$router.replace('/shouye')
      }else if(idx==1){
        this.$router.replace('/shequ')
      }else if(idx==2){
        this.$router.replace('/tianjia')
      }else if(idx==3){
        this.$router.replace('/qingdan')
      }else if(idx==4){
        this.$router.replace('/wode')
      }
    }
  }
}
</script>
<style>
  *{
    margin:0;
    padding:0;
  }
  .home {
  height: 100%;
  background-color: #F0F0F0;
}
</style>



